#ifndef __GAMEMANAGER_SCENE_H__
#define __GAMEMANAGER_SCENE_H__

#include "cocos2d.h"

class FlowController;
class CCBlade;
class Character;
class GameMap;
class Level;
class CatsManager;
class BaseCat;
class BaseSkill;
class SkillsLoader;
class LevelLoader;

//TODO: Testing AI Director
class AIDirector;
class PlayerPerformance;

class GameManager : public cocos2d::CCLayer
{
private:

	//Tag used for UI, it is also used for layer ordering as well
	const static int tagoffset = 100;

	enum {
		CHARACTER = 1,

		SWIPEEFFECT,

		HEALTHSPRITE,
		SKILLBARSPRITE,
		PROGRESSIONSPRITE,
		PROGRESSIONFLAGSPRITE,
		PROGRESSIONINDICATORSPRITE,

		SKILLSBUTTON,
		PAUSEBUTTON,

		SKILLS,

		PAUSEBG,
		PAUSETITLE,
		PAUSEMENU,
		PAUSESFX,
		PAUSEMUSIC,

		GAMEOVER,
		GAMEOVERBUTTONS
	};
	
	FlowController*					myFlowController;
	Character*						myCharacter;
	CatsManager*					myCatsManager;
	GameMap*						myMap;
	cocos2d::CCArray*				mySkills;
	Level*							myLevel;
	int								chargePoints;

	AIDirector*						myAIDirector;
	PlayerPerformance*				myPlayerPerformance;

	//Combo
	bool							comboOn;
	float							comboTimer;
	int								comboCounter;

	int								gameScore;

	//============================== Update function ==========================
	void 							update(float dt);
	//void 							updateComboCounter();

	//====================== Touch functions =====================
    std::map< cocos2d::CCTouch *, CCBlade * >  _map; //For touch swiping effect

    //====================== UI Buttons =====================
    cocos2d::CCArray*				myHealthUI;
    void							ReduceHealthUI(int health);

	cocos2d::CCArray*				mySkillChargeUI;
    void							adjustChargePointsUI(int amount);

    void							pauseButtonPressed(); //For pause button
    void							keyBackClicked(); //For back key button

    bool							isPaused;
    void 							resumeButtonPressedPaused(); //For Pause menu
    void 							restartButtonPressedPaused(); //For Pause menu / game over menu
    void 							exitButtonPressedPaused(); //For Pause menu
    void 							soundButtonPressedPaused(); //For Pause menu
    void 							musicButtonPressedPaused(); //For Pause menu
    void							forwardButtonPressedGameOver(); //For Game over menu

    bool							isGameOver;

public:
    //============================= Constructor and Initialistion ====================
	GameManager(void);
	~GameManager(void);
    virtual bool 					init();
    static GameManager*		 		createLayer();
    CREATE_FUNC(GameManager);

    //============================= Level Loading ================
    void							loadGame();

    //============================== Touches Methods ============================
    virtual void 					ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
    virtual void 					ccTouchesMoved(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
    virtual void 					ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);

    //============================== Accelerometer ===============================
    virtual void 					didAccelerate(cocos2d::CCAcceleration* pAccelerationValue);

    //============================= Skill Charge Points ===========================
    bool 							adjustChargePoint(int amount);

    //============================= End Game ===========================
    void							winGame();
    void 							endGame(bool isWin);

    //============================= Getters ===============================
    int								getChargePoints();
};

#endif // __GAMEMANAGER_SCENE_H__
